/*****************************************************************************
* Keppe Messenger (KMP) Keppe Project-Team User Messaging System
* Copyright (C) 2013-2014 Keppe Project-Team
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program.  If not, see <http://www.gnu.org/licenses/>.
*****************************************************************************/

#include "KCheckBox.h"
#include "ui_KCheckBox.h"

KCheckBox::KCheckBox(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::KCheckBox)
{
    ui->setupUi(this);
    setChecked(false);
}

KCheckBox::~KCheckBox()
{
    delete ui;
}

void KCheckBox::setChecked(bool newChecked)
{
    checked = newChecked;
    if (checked)
    {
        ui->checkBox->setPixmap(QPixmap(":/gui/cb-is.png"));
    }
    else
    {
        ui->checkBox->setPixmap(QPixmap(":/gui/cb-isnt.png"));
    }
}

void KCheckBox::on_checkBox_mousePress(QMouseEvent *)
{
    if (checked == true)
    {
        setChecked(false);
    }
    else
    {
        setChecked(true);
    }
}

void KCheckBox::on_text_mousePress(QMouseEvent *ev)
{
    on_checkBox_mousePress(ev);
}

void KCheckBox::setText(QString text)
{
    ui->text_->setText(text);
}

QString KCheckBox::text()
{
    QString text__ = ui->text_->text();
    return text__;
}

bool KCheckBox::isChecked()
{
    return checked;
}
